<% if card.published? %>
  <div data-turbo-permanent>
  <%= turbo_frame_tag card, :edit do %>
    <%# When canceling an edit (with the ESC key), restore the button area to show "Edit" instead of "Save changes". %>
    <%= turbo_stream.replace dom_id(card, :card_closure_toggle) do %>
      <%= render "cards/container/closure", card: card %>
    <% end %>

    <%= render "cards/container/content_display", card: card %>
  <% end %>
  </div>
<% else %>
  <%= form_with model: card, id: "card_form", data: { controller: "autoresize auto-save" } do |form| %>
    <h1 class="card__title">
      <%= form.label :title, class: "flex flex-column align-center autoresize__wrapper", data: { autoresize_target: "wrapper", autoresize_clone_value: "" } do %>
        <%= form.text_area :title, placeholder: "Name it…",
              class: "card-field__title autoresize__textarea input input--textarea full-width borderless txt-align-start hide-focus-ring hide-scrollbar",
              autofocus: card.title.blank?, rows: 1, dir: "auto", maxlength: 255,
              data: { autoresize_target: "textarea", action: "input->autoresize#resize auto-save#change blur->auto-save#submit keydown.enter->auto-save#submit:prevent" } %>
      <% end %>
    </h1>

    <%= form.rich_textarea :description, class: "card__description rich-text-content",
          placeholder: "Add some notes, context, pictures, or video about this…",
          data: { action: "lexxy:change->auto-save#change focusout->auto-save#submit" } do %>
      <%= general_prompts(card.board) %>
    <% end %>
  <% end %>
<% end %>
